package com.finalProject;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import androidx.fragment.app.Fragment;

import java.util.ArrayList;
import java.util.List;

/**
 * author: Jimmmy Smile
 * date: 2021-06-10 20:06::06
 * positioan: com.finalProject
 * e-mail:jimmysmileltl@163.com
 **/
public class  Fragment_Second extends Fragment {
    List<HousePrice> data = new ArrayList<HousePrice>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_second, null);
        ListView listView= view.findViewById(R.id.list_fragment_second);
        DBManager dbManager = new DBManager(getActivity());
        for (HousePrice hp : dbManager.listAll()) {
            data.add(hp);
            Log.i("fragment_second", "onCreate: "+hp.getCity());
        }
        AdapterOfHouseprice adapter=new AdapterOfHouseprice( getContext(), R.layout.list_item,
                data);
        listView.setAdapter(adapter);


    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_second, container, false);

    }
}